package com.kaifamiao.service.Impl;

import com.kaifamiao.mapper.ShijianduanMapper;
import com.kaifamiao.model.ShijianduanModel;
import com.kaifamiao.model.UserModel;
import com.kaifamiao.service.ShijianduanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
@Service("shijianduanService")
@Transactional(propagation = Propagation.REQUIRED)
public class ShijianduanServiceImpl implements ShijianduanService {

    @Autowired
    private ShijianduanMapper mapper;

    @Override
    public int addShijianduan(ShijianduanModel model) {
        Long id=model.getId();
        String timeName=model.getTimename();
        String begTime=model.getBegtime();
        String endTime=model.getEndtime();
        model.setId(id);
        model.setTimename(timeName);
        model.setBegtime(begTime);
        model.setEndtime(endTime);
        return mapper.insertSelective(model);
    }

    @Override
    public int updateShijianduan(ShijianduanModel model) {
        Long id=model.getId();
        String timeName=model.getTimename();
        String begTime=model.getBegtime();
        String endTime=model.getEndtime();
        model.setId(id);
        model.setTimename(timeName);
        model.setBegtime(begTime);
        model.setEndtime(endTime);
        return mapper.updateByPrimaryKeySelective(model);
    }

    @Override
    public int deleteShijianduan(Long id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<ShijianduanModel> findAll() {
        return mapper.selectAll();
    }
}
